home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Tools / icedump 6.018 and nticedump 1.9 / iceload.asm < prev    next >
Encoding:
Assembly Source File  |  2000-05-02  |  36.9 KB  |  1,691 lines

  1. ; iceload: NuMega SoftICE helper to load PE DLLs and break on DllMain
  2. ;
  3. ; usage: iceload [-r]|[-n] file.dll
  4. ;        iceload file.exe
  5. ;
  6. ; file name may specify path BUT should use SHORT names,
  7. ; or at least not contain spaces
  8. ;
  9. ; the optional -r switch will force the DLL to relocate
  10. ; (or not load if it cannot due to lack of relocations)
  11. ;
  12. ; the optional -n switch will notify SoftICE about the DLL
  13. ; but will not load it, instead one should start up the target
  14. ; app which uses the DLL. this switch obviously cannot be used
  15. ; with -r
  16. ;
  17. ; 2000/03/03    The Owl        created
  18. ; 2000/03/06    G-RoM        added GUI, Code reorganisation
  19. ; 2000/03/07    The Owl        fixed exe loading from commandline
  20. ; 2000/03/09    G-RoM        Changed NMTrans loading to make nmtrans
  21. ;                               preferred imagebase free for DLL to load.
  22. ; 2000/03/10    The Owl,G-RoM    -n switch
  23. ; 2000/03/10    G-RoM        Added status box writing.
  24. ; 2000/03/11    G-RoM        "enhanced" a bit the command line parser.
  25. ; 2000/03/14    G-RoM        Optimised rsrc and changed code accordingly.
  26. ;                Added some error checking about NMTRANS DLL.
  27. ; 2000/03/20    Muffin        added iceload.ini to remember last directory
  28. ; 2000/03/21    Muffin        fixed a lil bug which allowed to open non
  29. ;                existing file
  30. ; 2000/03/21    Muffin        added restore last screen position
  31. ; 2000/03/23    G-RoM        Optimizations.
  32. ; 2000/03/24    Muffin        added cmd line argument option, load exports
  33. ;                and save softice history
  34. ; 2000/03/25    Muffin        added Tooltips to Toolbar
  35. ; 2000/03/29    The Owl        rewrite + bugfixes
  36. ; 2000/05/02    Muffin        added keyboard acclerators, hey ho the_rain :)
  37. ;                CTRL+O = Open PE
  38. ;                CTRL+X = Exit
  39. ;                CTRL+R = Run
  40. ;                CTRL+L = Load exports
  41. ;                CTRL+S = Save SI history
  42. ;                CTRL+A = About
  43.  
  44.         BITS 32
  45.         %include "win32n.inc"
  46.         %include "kernel32.inc"
  47.         %include "user32.inc"
  48.         %include "comctl32.inc"
  49.         %include "comdlg32.inc"
  50.  
  51.         %include "iceload.inc"
  52.  
  53.         %include "nmtrans.inc"
  54.  
  55. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  56. ; global Definitions
  57. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  58. global _main
  59.  
  60. ;════════════════════════════════════════════════════════════════════════════
  61.  SEGMENT .bss     USE32 CLASS=BSS
  62. ;════════════════════════════════════════════════════════════════════════════
  63. Pstart        RESB    STARTUPINFO_size
  64. Pinfo        RESB    PROCESSINFORMATION_size
  65. oReloc        RESD    1
  66. oBase        RESD    1
  67. fCmdArgs    RESD    1
  68. fIsMinimized    RESD    1
  69. filename        RESD    1
  70. modinfo        RESB    ModuleLoadRecord_size
  71. BlockHeader     RESB    0x1000
  72. __Source        RESB    256
  73. HexBuffer       RESB    16
  74. IniDirBuffer    RESB    256
  75. ;────────────────────────────────────────────────────────────────────────────
  76. Align 4
  77. ;────────────────────────────────────────────────────────────────────────────
  78. hInst        RESD    1
  79. hToolBar        RESD    1
  80. hMain        RESD    1
  81. hAccel        RESD    1
  82. IL_wc        RESB    WNDCLASSEX_size
  83. IL_msg        RESB    MSG_size
  84. IL_ofn        RESB    OPENFILENAME_size
  85. IL_ButtonBar    RESB    TBBUTTON_size*9
  86. ;────────────────────────────────────────────────────────────────────────────
  87.  
  88.  
  89. ;════════════════════════════════════════════════════════════════════════════
  90.  SEGMENT .data    USE32 CLASS=DATA
  91. ;════════════════════════════════════════════════════════════════════════════
  92. HTable                  DB      '0123456789ABCDEF',0
  93. ;────────────────────────────────────────────────────────────────────────────
  94. strFilter        DB    'Executable Files',0,'*.exe;*.dll',0
  95.                         DB      'All files',0,'*.*',0,0
  96. strTitle        DB    'Choose Executable..',0
  97. strDefExt        DB    '*.exe',0
  98. strFilter2        DB    'Log Files',0,'*.log;*.txt',0
  99.                         DB      'All files',0,'*.*',0,0
  100. strDefLogExt        DB    '*.log',0
  101. ;────────────────────────────────────────────────────────────────────────────
  102. CR_LF                   DB      0Dh,0Ah,0h
  103. LoadedFile        DB    'Loaded ',0
  104. NotifiedWinice        DB    'SoftICE Notified',0
  105. Running                 DB      'Running ',0
  106. Missing            DB    ' is missing or target is not a PE !!', 0
  107. strExpLoaded        DB    'Exports loaded for: ',0
  108. strErrExpLoaded        DB    'Error loading exports !!',0
  109. strSiHistSaved        DB    'SoftICE history saved',0
  110. strErrSiHistSaved    DB    'Error saving SoftICE history !!',0
  111.  
  112. ;────────────────────────────────────────────────────────────────────────────
  113. NMLIB                   DB      'NMTRANS.DLL',0
  114. NMLoadRecord        DB    'NmSymGetModuleLoadRecord',0
  115. NMSetBreak        DB      'DevIO_SetWLDRBreak',0
  116. NMLoadExports        DB      'NmSymLoadExports',0
  117. NMCreateLog        DB      'NmSymCreateLogFile',0
  118. ;────────────────────────────────────────────────────────────────────────────
  119. IL_Class:
  120. strAppName        DB    'iceload',0
  121. strIniFile        DB    'iceload.ini',0
  122. strLastFile        DB    'LastFile',0
  123. strLastDir        DB    'LastDir',0
  124. strLastPos        DB    'LastPos',0
  125. ;════════════════════════════════════════════════════════════════════════════
  126. strTTOpenFile        DB    'Open PE file', 0
  127. strTTRun        DB    'Load/Run PE file',0
  128. strTTLoadExports    DB    'Load DLL exports',0
  129. strTTSaveHist        DB    'Save SoftICE history',0
  130. strExit            DB    'No you wont hit this button now :)', 0
  131. strAbout        DB    'About', 0
  132.  
  133. TT_Strings_Table:
  134. pszTTOpenFile        DD    strTTOpenFile
  135. pszTTRun        DD    strTTRun
  136. pszTTAbout        DD    strAbout
  137. pszTTExit        DD    strExit
  138. pszTTLoadExports    DD    strTTLoadExports
  139. pszTTSaveHist        DD    strTTSaveHist
  140.  
  141. ;════════════════════════════════════════════════════════════════════════════
  142.  
  143.  SEGMENT .text USE32 CLASS=CODE
  144. ;════════════════════════════════════════════════════════════════════════════
  145. _main:
  146.     call    ParseCmdLine
  147.     cmp    dword [filename],byte 0
  148.     jz    GUI
  149.  
  150.     push    dword [filename]
  151.     call    InitNmTransData
  152.     test    eax,eax
  153.     jz    .exit
  154.  
  155.     cmp    dword [modinfo+ModuleLoadRecord.Type],byte 2
  156.     jz    .exe
  157.  
  158.     call    HandleDLL
  159.     jmp    short .exit
  160.  
  161. .exe:
  162.     push    dword [filename]
  163.     call    LaunchEXE
  164.  
  165. .exit:
  166.     push    byte 0
  167.     call    ExitProcess
  168.  
  169.  
  170. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  171. ;Gui Code.
  172. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  173. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  174. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  175. GUI:
  176.     call    InitCommonControls    ; Force COMCTL32 Import
  177.  
  178.     push    byte 0
  179.     call    GetModuleHandleA
  180.     mov    [hInst], eax
  181.     
  182.     call    InitGUI
  183.     test    eax,eax
  184.     jz    _main.exit
  185.  
  186. .msg_loop:
  187.     xor    eax, eax
  188.     push    eax
  189.     push    eax
  190.     push    eax
  191.     push    dword IL_msg
  192.         call     GetMessageA
  193.     test    eax, eax
  194.     jz    _main.exit
  195.  
  196.     push    dword IL_msg
  197.     push    dword [hAccel]
  198.     push    dword [hMain]
  199.     call    TranslateAcceleratorA
  200.     test    eax, eax
  201.     jnz    .msg_loop
  202.  
  203.     push    dword IL_msg
  204.     push    dword [hMain]
  205.     call    IsDialogMessage
  206.     test    eax, eax
  207.     jnz    .msg_loop
  208.     
  209.     push    dword IL_msg
  210.         call     TranslateMessage
  211.  
  212.     push    dword IL_msg
  213.         call     DispatchMessageA
  214.     jmp    short .msg_loop
  215.  
  216.  
  217. ;-------------------------------------------------------------------------------
  218. ;
  219. ;-------------------------------------------------------------------------------
  220. InitGUI:
  221.     mov    [IL_wc+WNDCLASSEX.hInstance], eax
  222.     mov    dword [IL_wc+WNDCLASSEX.cbSize], WNDCLASSEX_size
  223.     mov    dword [IL_wc+WNDCLASSEX.style], CS_HREDRAW + CS_VREDRAW
  224.     mov    dword [IL_wc+WNDCLASSEX.lpfnWndProc], DlgProc
  225.     mov    dword [IL_wc+WNDCLASSEX.cbClsExtra],0
  226.     mov    dword [IL_wc+WNDCLASSEX.cbWndExtra],DLGWINDOWEXTRA
  227.  
  228. ; load main icon from resource
  229.     push    dword ICON_MAIN
  230.     push    eax
  231.     call     LoadIconA
  232.     mov    [IL_wc+WNDCLASSEX.hIcon], eax
  233.     mov    [IL_wc+WNDCLASSEX.hIconSm], eax
  234.  
  235. ; load a default cursor
  236.     push    dword IDC_ARROW
  237.     push    byte 0
  238.       call     LoadCursorA
  239.     mov    [IL_wc+WNDCLASSEX.hCursor], eax
  240.     mov    dword [IL_wc+WNDCLASSEX.hbrBackground], COLOR_WINDOW
  241.     mov    dword [IL_wc+WNDCLASSEX.lpszMenuName], 0
  242.     mov    dword [IL_wc+WNDCLASSEX.lpszClassName], IL_Class
  243.  
  244.     push    dword IL_wc
  245.     call     RegisterClassExA
  246.     test    eax, eax
  247.     jnz    .1
  248.  
  249.     retn
  250.  
  251. .1:
  252.     xor    eax, eax
  253.     push    eax
  254.     push    eax
  255.     push    eax
  256.     push    dword IL_Class
  257.     push    dword [hInst]
  258.     call    CreateDialogParamA
  259.     mov    [hMain], eax        ; We have now owner
  260.  
  261.     mov    eax, IL_ButtonBar
  262.     mov    [eax+0*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  263.      mov    [eax+0*TBBUTTON_size+TBBUTTON.fsStyle], byte TBSTYLE_SEP     ; Type
  264.  
  265.     mov    [eax+1*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  266.      mov    [eax+1*TBBUTTON_size+TBBUTTON.idCommand], dword IL_OPEN      ; Type
  267.  
  268.     mov    [eax+2*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  269.      mov    [eax+2*TBBUTTON_size+TBBUTTON.fsStyle], byte TBSTYLE_SEP     ; Type
  270.  
  271.     mov    [eax+3*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  272.      mov    [eax+3*TBBUTTON_size+TBBUTTON.idCommand], dword IL_RUN       ; Type
  273.     mov    [eax+3*TBBUTTON_size+TBBUTTON.iBitmap], byte 1
  274.  
  275.     mov    [eax+4*TBBUTTON_size+TBBUTTON.idCommand], dword IL_LOAD_EXP  ; Type
  276.     mov    [eax+4*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  277.     mov    [eax+4*TBBUTTON_size+TBBUTTON.iBitmap], byte 4
  278.  
  279.     mov    [eax+5*TBBUTTON_size+TBBUTTON.idCommand], dword IL_SAVE_SIHIST  ; Type
  280.     mov    [eax+5*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  281.     mov    [eax+5*TBBUTTON_size+TBBUTTON.iBitmap], byte 5
  282.  
  283.     mov    [eax+6*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  284.      mov    [eax+6*TBBUTTON_size+TBBUTTON.fsStyle], byte TBSTYLE_SEP     ; Type
  285.  
  286.      mov    [eax+7*TBBUTTON_size+TBBUTTON.idCommand], dword IL_ABOUT     ; Type
  287.     mov    [eax+7*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  288.     mov    [eax+7*TBBUTTON_size+TBBUTTON.iBitmap], byte 2
  289.  
  290.     mov    [eax+8*TBBUTTON_size+TBBUTTON.idCommand], dword IL_EXIT      ; Type
  291.     mov    [eax+8*TBBUTTON_size+TBBUTTON.fsState], byte TBSTATE_ENABLED ; State
  292.     mov    [eax+8*TBBUTTON_size+TBBUTTON.iBitmap], byte 3
  293.  
  294.     push    byte TBBUTTON_size
  295.     push    byte 16
  296.     push    byte 16
  297.     push    byte 16
  298.     push    byte 16
  299.     push    byte 09
  300.     push    dword IL_ButtonBar
  301.     push    dword IL_TOOLBAR
  302.     push    dword [hInst]
  303.     push    byte 04
  304.     push    byte 00
  305.     push    dword TBSTYLE_TOOLTIPS+WS_CHILD
  306.     push    dword [hMain]
  307.     call    CreateToolbarEx
  308.     mov    [hToolBar], eax
  309.  
  310.     push    byte TRUE
  311.     push    eax
  312.     call    ShowWindow
  313.  
  314.     push    byte  FALSE
  315.     push    dword IL_RUN
  316.     push    dword TB_ENABLEBUTTON
  317.     push    dword [hToolBar]
  318.     call    SendMessageA
  319.  
  320.     push    dword IDR_ACCELERATOR
  321.     push    dword [hInst]
  322.     call    LoadAcceleratorsA
  323.     mov    [hAccel], eax
  324.  
  325.     xor    eax, eax
  326.     inc    eax
  327.  
  328.     retn
  329.  
  330.  
  331. ;-------------------------------------------------------------------------------
  332. ; cmdline parsing
  333. ; 1. find end of own file name
  334. ; 2. extract dll/exe file name from the end of the command line
  335. ; 3. if found and it's a DLL check for cmdline switches
  336. ;-------------------------------------------------------------------------------
  337. ParseCmdLine:
  338.     push    ecx
  339.     push    edi
  340.  
  341.     call    GetCommandLineA
  342.     mov    edi,eax
  343.     mov    al,[edi]
  344.     or    ecx,byte -1
  345.     cmp    al,'"'            ; long file name?
  346.     jnz    .find_tail
  347.  
  348.     inc    edi
  349.     repnz    scasb            ; find terminating "
  350.     dec    edi
  351.  
  352. .find_tail:
  353.     inc    edi
  354.     cmp    [edi],byte 0
  355.     jz    .ret
  356.  
  357.     cmp    [edi],byte ' '
  358.     jnz    .find_tail
  359.  
  360.     xor    eax, eax
  361.     lea    ecx,[eax-1]
  362.     repnz    scasb
  363.     not    ecx
  364.  
  365.     dec    edi
  366.     dec    edi            ; edi: last char of cmdline
  367.     mov    al,' '
  368.     std                ; search backwards
  369.     repe    scasb            ; find space at the end of the cmdline
  370.     repne    scasb            ; find space separating params
  371.     cld
  372.     jne    .ret
  373.  
  374.     inc    edi
  375.     inc    edi            ; edi: beginning of the file name
  376.  
  377.     mov    [filename],edi
  378.  
  379. .ret:
  380.     pop    edi
  381.     pop    ecx
  382.     retn
  383.  
  384.  
  385. ;-------------------------------------------------------------------------------
  386. ;
  387. ;-------------------------------------------------------------------------------
  388. InitNmTransData:
  389.     push    ebp
  390.     mov    ebp, esp
  391.     sub    esp, 4
  392.     push    esi
  393.     push    edi
  394.     push    ecx
  395.     push    edx
  396.     push    ebx
  397.  
  398.     push    dword NMLIB
  399.     call    LoadLibraryA            ; Load NMTrans
  400.     test    eax, eax
  401.     jz    near .exit
  402.  
  403.     mov    [ebp-4], eax
  404.  
  405.     push    dword NMLoadRecord
  406.     push    dword [ebp-4]
  407.     call    GetProcAddress          ; Get GetModuleRecord Address
  408.     test    eax, eax
  409.     jz      .freeexit
  410.  
  411.     push    dword modinfo
  412.     push    dword [ebp+08h]
  413.     call    eax            ; _NmSymGetModuleLoadRecord
  414.     add    esp,byte 8
  415.     test    eax,eax
  416.     jz    .freeexit
  417.  
  418. ; see what sort of file it is, we're using nmtrans and its IDs
  419. ; 2: PE exe
  420. ; 3: PE dll
  421. ; then we notify softice to watch for this dll load and to break at DllMain
  422.     mov    ebx,[modinfo+ModuleLoadRecord.Type]
  423.     cmp    ebx,byte 2        ; exe?
  424.     jz    .EXE
  425.  
  426.     xor    eax, eax
  427.     cmp    ebx,byte 3        ; dll?
  428.     jnz    .freeexit
  429.  
  430. .EXE:
  431.     movzx    ebx,word [modinfo+0x134]
  432.     push    ebx
  433.     push    byte 1            ; flag: set BPX on entry point
  434.     movzx    eax,word [modinfo+0x132]
  435.     push    eax
  436.     push    dword [modinfo+ModuleLoadRecord.EntryRVA]
  437.     push    dword modinfo+ModuleLoadRecord.ModName
  438.     push    dword NMSetBreak
  439.     push    dword [ebp-4]
  440.     call    GetProcAddress        ; Get SetBreakPoint Address
  441.     test    eax, eax
  442.     jz    .freeexit
  443.  
  444.     call    eax            ; _DevIO_SetWLDRBreak
  445.     add    esp, byte 5*4
  446.     xor    eax, eax
  447.     inc    eax
  448.  
  449. .freeexit:
  450.     push    eax
  451.     push    dword [ebp-4]
  452.     call    FreeLibrary        ; Free NmTrans
  453.     pop    eax
  454.  
  455. .exit:
  456.     pop    ebx
  457.     pop    edx
  458.     pop    ecx
  459.     pop    edi
  460.     pop    esi
  461.     add    esp, byte 4
  462.     pop    ebp
  463.     retn    04h
  464.  
  465.  
  466. ;-------------------------------------------------------------------------------
  467. ;
  468. ;-------------------------------------------------------------------------------
  469. HandleDLL:
  470.     push    ecx
  471.     push    edi
  472.  
  473. ; check for optional -r switch and allocate (reserve) memory at the dll's
  474. ; base so that it will have to be relocated
  475.     mov    edi,[filename]
  476.     mov    ecx,edi
  477.     call    GetCommandLineA
  478.     sub    ecx,eax
  479.     mov    al,'-'
  480.     std
  481.     repnz    scasb
  482.     cld
  483.     xor    eax, eax
  484.     jecxz    .load
  485.  
  486.     cmp    dword [edi],' -r '
  487.     jnz    .noreloc
  488.  
  489.     push    dword BlockHeader
  490.     push    dword [filename]
  491.     call    GrabHeader
  492.  
  493.     push    dword BlockHeader
  494.     call    CheckPE
  495.     add    eax, BlockHeader
  496.     mov    eax, [eax+34h]        ; ImageBase
  497.     jmp    short .load
  498.  
  499. .noreloc:
  500. ; check for optional -n switch and exit if specified, this way we will have
  501. ; notified softice by now but will not load the DLL ourselves thus won't
  502. ; trigger the BPX set by softice. instead the user should start up an app
  503. ; that loads his target DLL and off he goes...
  504.     cmp    dword [edi],' -n '
  505.     jz    .ret
  506.  
  507. ; here should come some dire warning about bad cmdline... oh well, next time
  508.  
  509. .load:
  510.     push    eax
  511.     push    dword [filename]
  512.     Call    LoadDLL
  513.  
  514. .ret:
  515.     pop    edi
  516.     pop    ecx
  517.     retn
  518.  
  519.  
  520. ;-------------------------------------------------------------------------------
  521. ;
  522. ;-------------------------------------------------------------------------------
  523. LoadDLL:
  524.     push    ebp
  525.     mov    ebp, esp
  526.     sub    esp, byte 4
  527.     push    esi
  528.     push    edi
  529.     push    ecx
  530.     push    edx
  531.     push    ebx
  532.  
  533.     xor    eax, eax
  534.     mov    [ebp-4], eax
  535.     cmp    dword [ebp+0Ch], byte 0
  536.     jz    .noreloc
  537.  
  538.     push    byte PAGE_NOACCESS
  539.     push    dword MEM_RESERVE
  540.     push    dword 0x1000
  541.     push    dword [ebp+0Ch]
  542.     call    VirtualAlloc
  543.     mov    [ebp-4], eax
  544.  
  545. .noreloc:
  546.     push    dword [ebp+08h]
  547.     call    LoadLibraryA
  548.  
  549.     push    eax
  550.     call    FreeLibrary
  551.  
  552.     cmp    dword [ebp-4],byte 0
  553.     jz    .exit
  554.  
  555.     push    dword MEM_RELEASE
  556.     push    byte 0
  557.     push    dword [ebp-4]
  558.     call    VirtualFree
  559. .exit:
  560.     pop    ebx
  561.     pop    edx
  562.     pop    ecx
  563.     pop    edi
  564.     pop    esi
  565.     add    esp, byte 4
  566.     pop    ebp
  567.     retn    08h
  568.  
  569.  
  570. ;-------------------------------------------------------------------------------
  571. ;
  572. ;-------------------------------------------------------------------------------
  573. LaunchEXE:
  574.     push    ebp
  575.     mov    ebp,esp
  576.     sub    esp, dword 256
  577.     push    edi
  578.  
  579.     lea    edi, [ebp - 256]
  580.     push    dword [ebp+8]
  581.     push    edi
  582.     call    lstrcpyA            ;copy path+exe to buff
  583.  
  584.     cmp    byte [fCmdArgs], 1        ;cmd arg checkbox checked?
  585.     jnz    near .no_cmdargs
  586.  
  587.     push    edi
  588.     call    lstrlenA
  589.  
  590.     lea    edi, [edi +  eax ]        ;point to end of buff
  591.     mov    dword [edi], ' '
  592.     inc     edi
  593.  
  594.     lea    eax, [eax - 255]
  595.     neg    eax                ;calc max chars
  596.     push    eax
  597.     push    edi
  598.     push    dword IL_ARGUMENTS
  599.     push    dword [ebp+40]
  600.     call    GetDlgItemTextA
  601.  
  602. .no_cmdargs:
  603.     mov    dword [Pstart+STARTUPINFO.cb], STARTUPINFO_size
  604.     xor    eax, eax
  605.     lea    edi, [ebp - 256]
  606.  
  607.     push     dword Pinfo
  608.     push    dword Pstart
  609.     push     eax
  610.     push     eax
  611.     push     byte 30h
  612.     push     eax
  613.     push     eax
  614.     push     eax
  615.     push     edi                ;[ebp+8]
  616.     push     eax
  617.     call     CreateProcessA
  618.  
  619.     pop    edi
  620.     add    esp, dword 256
  621.     pop    ebp
  622.     retn    4
  623.  
  624.  
  625. ;-------------------------------------------------------------------------------
  626. ;esp+4 : hwnd:DWORD
  627. ;esp+8 : wmsg:DWORD
  628. ;esp+c : wparam:DWORD
  629. ;esp+10: lparam:DWORD
  630. ;-------------------------------------------------------------------------------
  631. DlgProc:
  632.     push    ebp
  633.     mov    ebp, esp
  634.     push    esi
  635.     push    edi
  636.     push    ecx
  637.     push    edx
  638.     push    ebx
  639.  
  640.     mov    eax, [ebp+0Ch]
  641.  
  642.     cmp    eax, byte WM_CREATE
  643.     jz    .wmcreate
  644.  
  645.     cmp     eax, WM_COMMAND      ; Control used ?
  646.     jz      near .wmcommand
  647.  
  648.     cmp    eax, byte WM_DESTROY    ; Window closed ?
  649.     jz    near .wmdestroy
  650.  
  651.     cmp    eax, byte WM_CLOSE    ; Window closed ?
  652.     jz    near .wmclose
  653.  
  654.     cmp    eax, WM_SIZE
  655.     jz    near .wm_size
  656.     
  657.     cmp    eax, WM_NOTIFY
  658.     jz    near .wm_notify
  659.     jmp    near .ReturnZERO
  660.  
  661. .wmcreate:
  662.     push    dword [ebp+08]
  663.     call    CenterWindow
  664.  
  665.     push    dword [ebp+08]
  666.     call    RestoreLastPos
  667.     call    GetLastFile
  668.  
  669.      mov    dword [IL_ofn+OPENFILENAME.lStructSize], OPENFILENAME_size
  670.     mov    eax, [ebp+08h]
  671.     mov    [IL_ofn+OPENFILENAME.hwndOwner], eax
  672.     mov    eax, [hInst]
  673.     mov    [IL_ofn+OPENFILENAME.hInstance], eax
  674.     mov    dword [IL_ofn+OPENFILENAME.lpstrFilter], strFilter
  675.     mov    dword [IL_ofn+OPENFILENAME.lpstrFile], __Source
  676.     mov    dword [IL_ofn+OPENFILENAME.nMaxFile], 256
  677.     mov    dword [IL_ofn+OPENFILENAME.Flags], OFN_HIDEREADONLY | OFN_FILEMUSTEXIST
  678.     mov    dword [IL_ofn+OPENFILENAME.lpstrDefExt], strDefExt
  679.     xor    eax, eax
  680.     mov    [oBase], eax
  681.     mov    [oReloc], eax
  682.     jmp    .ReturnZERO
  683.  
  684. .wmcommand:
  685.     movzx    eax, word [ebp+10h]
  686.     
  687.     cmp    eax, IL_OPEN
  688.     jz    .ilc_open
  689.  
  690.     cmp    eax, IL_RUN
  691.     jz    near .ilc_run
  692.  
  693.     cmp    eax, IL_LOAD_EXP
  694.     jz    near .ilc_loadexp
  695.  
  696.     cmp    eax, IL_SAVE_SIHIST
  697.     jz    near .ilc_save_sihist
  698.  
  699.     cmp    eax, IL_EXIT
  700.     jz    near .ilc_exit
  701.  
  702.     cmp    eax, IL_ABOUT
  703.     jz    near .ilc_about
  704.  
  705.     cmp    eax, IL_RELOC
  706.     jz    near .ilc_reloc
  707.  
  708.     cmp    eax, IL_CKB_ARGS
  709.     jz    near .ilc_args
  710.     jmp    near .ReturnZERO
  711.  
  712. .wm_notify:
  713.     push    dword [ebp+14h]        ;lparam
  714.     call    SetToolbarTTs
  715.     jmp    near .ReturnZERO
  716.  
  717. .ilc_open:
  718.     push    dword IL_ofn
  719.     call    GetOpenFileNameA
  720.     test    eax, eax
  721.     jz    near .ReturnZERO
  722.  
  723.     push    dword __Source
  724.     Call    InitNmTransData
  725.     test    eax, eax
  726.     jz    near .Err_nmtrans
  727.  
  728.     call    UpdateIni
  729.  
  730.     push    byte 0
  731.     push    dword LoadedFile
  732.     push    dword IL_STATUS
  733.     push    dword [ebp+08h]
  734.     Call    TextBoxWrite
  735.  
  736.     push    byte 1
  737.     push    dword __Source
  738.     push    dword IL_STATUS
  739.     push    dword [ebp+08h]
  740.     Call    TextBoxWrite
  741.  
  742.     push    dword BlockHeader
  743.     push    dword __Source
  744.     call    GrabHeader
  745.  
  746.     push    dword BlockHeader
  747.     call    CheckPE
  748.     add    eax, BlockHeader
  749.     mov    eax, [eax+34h]        ; ImageBase
  750.     mov    [oBase], eax
  751.  
  752.     push    dword HexBuffer
  753.     push    dword [oBase]
  754.     call    Dword2Hex
  755.  
  756.     push    dword HexBuffer
  757.     push    dword IL_RELOCBASE
  758.     push    dword [ebp+08h]
  759.     call    SetDlgItemTextA
  760.  
  761.     push    byte 1
  762.     push    dword NotifiedWinice
  763.     push    dword IL_STATUS
  764.     push    dword [ebp+08h]
  765.     Call    TextBoxWrite
  766.  
  767.     push    byte  TRUE
  768.     push    dword IL_RUN
  769.     push    dword TB_ENABLEBUTTON
  770.     push    dword [hToolBar]
  771.     call    SendMessageA
  772.  
  773.     push    dword IL_RELOC
  774.     push    dword [ebp+08h]
  775.     call    GetDlgItem
  776.  
  777.     mov    bl, [modinfo+ModuleLoadRecord.Type]
  778.  
  779.     push    byte 02h
  780.     xor    byte [esp], bl
  781.     push    eax
  782.     call    EnableWindow
  783.  
  784.     push    dword IL_CKB_ARGS
  785.     push    dword [ebp+08h]
  786.     call    GetDlgItem
  787.  
  788.     push    byte 03h
  789.     xor    byte [esp], bl
  790.     push    eax
  791.     call    EnableWindow
  792.     jmp    .ReturnZERO
  793.  
  794. .ilc_exit:
  795.     jmp    .wmclose
  796.  
  797. .ilc_loadexp:
  798.     push    dword [ebp+08h]
  799.     call    LoadExports
  800.     jmp    .ReturnZERO
  801.  
  802. .ilc_save_sihist:
  803.     push    dword [ebp+08h]
  804.     call    SaveSIHist
  805.     jmp    .ReturnZERO
  806.  
  807. .ilc_run:
  808.     push    byte  0
  809.     push    dword IL_RUN
  810.     push    dword TB_GETSTATE
  811.     push    dword [hToolBar]
  812.     call    SendMessageA
  813.  
  814.     cmp    eax, TBSTATE_ENABLED
  815.     jnz    near .ReturnZERO
  816.  
  817.     push    dword __Source
  818.     Call    InitNmTransData
  819.     test    eax, eax
  820.     jz    near .Err_nmtrans
  821.  
  822.     push    byte 0
  823.     push    dword Running
  824.     push    dword IL_STATUS
  825.     push    dword [ebp+08h]
  826.     Call    TextBoxWrite
  827.  
  828.     push    byte 1
  829.     push    dword __Source
  830.     push    dword IL_STATUS
  831.     push    dword [ebp+08h]
  832.     Call    TextBoxWrite
  833.  
  834.     cmp    byte [modinfo+ModuleLoadRecord.Type], 3
  835.     jz    .DealWithDLL
  836.  
  837.     cmp    byte [modinfo+ModuleLoadRecord.Type], 2
  838.     jnz    near .ReturnZERO
  839.  
  840.     push     dword __Source
  841.     call    LaunchEXE
  842.     jmp    .ReturnZERO
  843.  
  844. .DealWithDLL:
  845.     mov    dword [oBase], 0
  846.     cmp    byte [oReloc], 1
  847.     jnz    .NoReloc
  848.  
  849.     push    byte 16
  850.     push    dword HexBuffer
  851.     push    dword IL_RELOCBASE
  852.     push    dword [ebp+08h]
  853.     call    GetDlgItemTextA
  854.  
  855.     push    dword HexBuffer
  856.     call    Hex2Dec
  857.     mov    [oBase], eax
  858.  
  859. .NoReloc:
  860.     push    dword [oBase]
  861.     push    dword __Source
  862.     call    LoadDLL
  863.     jmp    .ReturnZERO
  864.  
  865. .ilc_about:
  866.     push    byte 0
  867.     push    dword AboutProc
  868.     push    dword [ebp+8]
  869.     push    dword ILABOUT
  870.     push    dword [hInst]
  871.     call    DialogBoxParamA
  872.  
  873.     push    dword [ebp+8]
  874.     call    UpdateWindow
  875.     jmp    .ReturnZERO
  876.  
  877. .ilc_reloc:
  878.     xor    dword [oReloc], byte 1
  879.  
  880.     push    dword IL_RELOCBASE
  881.     push    dword [ebp+08h]
  882.     call    GetDlgItem
  883.  
  884.     push    dword [oReloc]
  885.     push    eax
  886.     call    EnableWindow
  887.     jmp    .ReturnZERO
  888.  
  889. .ilc_args:
  890.     xor    dword [fCmdArgs], byte 1
  891.  
  892.     push    dword IL_ARGUMENTS
  893.     push    dword [ebp+08h]
  894.     call    GetDlgItem
  895.  
  896.     push    dword [fCmdArgs]
  897.     push    eax
  898.     call    EnableWindow
  899.     jmp    .ReturnZERO
  900.  
  901. .Err_nmtrans:
  902.     push    byte 0
  903.     push    dword NMLIB
  904.     push    dword IL_STATUS
  905.     push    dword [ebp+08h]
  906.     Call    TextBoxWrite
  907.  
  908.     push    byte 1
  909.     push    dword Missing
  910.     push    dword IL_STATUS
  911.     push    dword [ebp+08h]
  912.     Call    TextBoxWrite
  913.  
  914.     push    byte  FALSE
  915.     push    dword IL_RUN
  916.     push    dword TB_ENABLEBUTTON
  917.     push    dword [hToolBar]
  918.     call    SendMessageA
  919.     jmp    .ReturnZERO
  920.  
  921. .wm_size:
  922.     mov    byte [fIsMinimized], 0
  923.     cmp    word [ebp+10h], SIZE_MINIMIZED
  924.     jnz    .ReturnZERO
  925.  
  926.     mov    byte [fIsMinimized], 1
  927.     jmp    .ReturnZERO
  928.  
  929. .wmclose:
  930.     push    dword [ebp+08h]
  931.     call    SaveCurrentPos            ;save screen pos to ini
  932.  
  933.     push    byte 0
  934.     push    dword [ebp+08h]
  935.     call    EndDialog
  936.  
  937. .wmdestroy:
  938.     push    byte 0
  939.     call    PostQuitMessage
  940.  
  941. .ReturnZERO:
  942.     push    dword [ebp+14h]
  943.      push    dword [ebp+10h]
  944.      push    dword [ebp+0Ch]
  945.      push    dword [ebp+08h]
  946.     call    DefWindowProcA
  947.  
  948. .EndDlgProc:
  949.     pop    ebx
  950.     pop    edx
  951.     pop    ecx
  952.     pop    edi
  953.     pop    esi
  954.     pop    ebp
  955.     retn    10h
  956.  
  957.  
  958. AboutProc:
  959.     push    ebp
  960.     mov    ebp, esp
  961.     push    esi
  962.     push    edi
  963.     push    ecx
  964.     push    edx
  965.     push    ebx
  966.  
  967.     mov    eax, [ebp+0Ch]
  968.  
  969.     cmp    eax, WM_INITDIALOG
  970.     jz    .AboutCreate
  971.  
  972.     cmp    eax, WM_COMMAND
  973.     jnz    .Default
  974.  
  975.     mov    eax, [ebp+10h]
  976.     cmp    eax, IDBOK
  977.     jz     .AboutEnd
  978.  
  979.     cmp    eax, byte IDOK
  980.     jz     .AboutEnd
  981.  
  982.     cmp    eax, byte IDCANCEL
  983.     jnz     .Default
  984.  
  985. .AboutEnd:
  986.     push    byte TRUE
  987.     push    dword [ebp+08h]
  988.     call    EndDialog
  989.     xor    eax, eax
  990.     inc    eax
  991.     jmp    .Return
  992.  
  993. .AboutCreate:
  994.     push    dword [ebp+08h]
  995.     call    CenterWindow
  996.     jmp    .Return
  997.  
  998. .Default:
  999.           xor     eax, eax
  1000.  
  1001. .Return:
  1002.     pop    ebx
  1003.     pop    edx
  1004.     pop    ecx
  1005.     pop    edi
  1006.     pop    esi
  1007.     pop    ebp
  1008.     retn    10h
  1009.  
  1010.  
  1011. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1012. ; Convert an hexstring to dword value.
  1013. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1014.  
  1015. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1016. ;esp+4 : String hex To convert
  1017. ;
  1018. ;eax=HEX value
  1019. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1020. Hex2Dec:
  1021.     push    esi
  1022.     push    edx
  1023.  
  1024.     mov    esi, [esp+04+08h]
  1025.     xor    edx, edx
  1026.  
  1027. HexConvert:
  1028.     xor    eax, eax
  1029.     lodsb
  1030.     test    eax, eax
  1031.     jz    EndHex2Dec
  1032.  
  1033.     sub    al, '0'
  1034.     cmp    al, 9h
  1035.     jle    WasDigit
  1036.  
  1037.     sub    al, 'A'-('0'+0Ah)
  1038.  
  1039. WasDigit:
  1040.     shl    edx, 4
  1041.     add    edx, eax
  1042.     jmp    short HexConvert
  1043.  
  1044. EndHex2Dec:
  1045.     mov    eax, edx
  1046.  
  1047.     pop    edx
  1048.     pop    esi
  1049.     retn    04h
  1050.  
  1051.  
  1052. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1053. ; Convert a Dword to its Hex String.
  1054. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1055.  
  1056. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1057. ;esp+4 : Value to Convert.
  1058. ;esp+8 : Buffer where to Store.
  1059. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1060. Dword2Hex:
  1061.     push    edi
  1062.     push    ecx
  1063.     push    ebx
  1064.  
  1065.     mov    eax, [esp+04h+0Ch]
  1066.     mov    edi, [esp+08h+0Ch]
  1067.  
  1068.      mov    ecx,4
  1069.      xor    ebx,ebx
  1070.  
  1071. Convert_it:
  1072.      rol    eax,8      ; rotate 8 bits
  1073.      push    eax
  1074.      xor    bh,bh
  1075.      mov    bl,al
  1076.      mov    dl,al
  1077.      shr    bl,4
  1078.      mov    al,[ebx+HTable]
  1079.      stosb
  1080.      mov    bl,dl
  1081.      and    bl,0Fh
  1082.      mov    al,[ebx+HTable]
  1083.      stosb
  1084.      pop    eax
  1085.      dec    ecx
  1086.      jnz    Convert_it
  1087.  
  1088.     pop    ebx
  1089.     pop    ecx
  1090.     pop    edi
  1091.     retn    08h
  1092.  
  1093.  
  1094. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1095. ; Center the given window on the screen.
  1096. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1097. CenterWindow:
  1098.     push    ebp
  1099.     mov    ebp, esp
  1100.     sub    esp, byte RECT_size
  1101.     push    esi
  1102.     push    edi
  1103.     push    ecx
  1104.     push    edx
  1105.     push    ebx
  1106.  
  1107.     call    GetDesktopWindow
  1108.  
  1109.     lea    edi, [ebp-RECT_size]
  1110.     push    edi
  1111.     push    eax
  1112.     call    GetWindowRect
  1113.  
  1114.     push    dword [edi+RECT.right]
  1115.     push    dword [edi+RECT.bottom]
  1116.  
  1117.     push    edi
  1118.     push    dword [ebp+08h]
  1119.     call    GetWindowRect
  1120.  
  1121.     mov    eax, [edi+RECT.bottom]
  1122.     sub    eax, [edi+RECT.top]
  1123.     pop    ecx
  1124.     sub    ecx, eax               ; save EAX
  1125.     shr    ecx, 1
  1126.  
  1127.     mov    ebx, [edi+RECT.right]
  1128.     sub    ebx, [edi+RECT.left]
  1129.     pop    edx
  1130.     sub    edx, ebx
  1131.     shr    edx, 1
  1132.  
  1133.     push    byte TRUE
  1134.     push    eax
  1135.     push    ebx
  1136.     push    ecx
  1137.     push    edx
  1138.     push    dword [ebp+08h]
  1139.     call    MoveWindow
  1140.  
  1141.     pop    ebx
  1142.     pop    edx
  1143.     pop    ecx
  1144.     pop    edi
  1145.     pop    esi
  1146.     add    esp, byte RECT_size
  1147.     pop    ebp
  1148.     retn    04h
  1149.  
  1150.  
  1151. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1152. ; Write to TextBox.
  1153. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1154.  
  1155. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1156. ;esp+4 : hwnd.
  1157. ;esp+8 : TextBox ID.
  1158. ;esp+c : String
  1159. ;esp+10: \n or not
  1160. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1161. TextBoxWrite:
  1162.     push    ebp
  1163.     mov    ebp, esp
  1164.     sub    esp, byte 4
  1165.     pushad
  1166.  
  1167.     push    dword [ebp+0Ch]
  1168.     push    dword [ebp+08h]
  1169.     Call    GetDlgItem
  1170.     mov    [ebp-4], eax
  1171.  
  1172.     push    eax
  1173.     call    GetWindowTextLengthA    ; Get edit text length
  1174.  
  1175.     push    eax
  1176.     push    eax
  1177.     push    dword EM_SETSEL
  1178.     push    dword [ebp-4]
  1179.     call    SendMessageA        ; Set Caret to last char
  1180.  
  1181.     push    dword [ebp+10h]
  1182.     push    byte FALSE
  1183.     push    dword EM_REPLACESEL
  1184.     push    dword [ebp-4]
  1185.     call    SendMessageA        ; Append new text
  1186.  
  1187.     push    dword [ebp-4]
  1188.     call    SetFocus        ; Set Focus to Edit Child
  1189.  
  1190.     cmp    [ebp+14h], byte 1       ; Add Return chars ?
  1191.     jnz    .EndTextWrite
  1192.  
  1193.     push    byte 0
  1194.     push    dword CR_LF
  1195.     push    dword [ebp+0Ch]
  1196.     push    dword [ebp+08h]
  1197.     call    TextBoxWrite
  1198.  
  1199. .EndTextWrite:
  1200.     popad
  1201.     add    esp, byte 4
  1202.     pop    ebp
  1203.     ret      10h
  1204.  
  1205.  
  1206. ; utility functions to check/load PE headers
  1207. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1208. ;Grab PE header.
  1209. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1210.  
  1211. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1212. ;esp+4 : FileName
  1213. ;esp+8 : hPEBuffer
  1214. ;
  1215. ;eax=1, 0 otherwise.
  1216. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1217. GrabHeader:
  1218.     push    ebp
  1219.     mov    ebp, esp
  1220.     sub    esp, byte 4
  1221.     push    esi
  1222.     push    edi
  1223.     push    ecx
  1224.     push    edx
  1225.     push    ebx
  1226. ;────────────────────────────────────────────────────────────────────────────
  1227. ; Open file.
  1228. ;────────────────────────────────────────────────────────────────────────────
  1229.     xor    eax, eax
  1230.     push     eax
  1231.     push     eax
  1232.     push     byte OPEN_EXISTING
  1233.     push     eax
  1234.     push     byte FILE_SHARE_READ
  1235.     push     dword GENERIC_READ
  1236.     push     dword [ebp+08h]         ; offset FileName
  1237.     call     CreateFileA            ; open file in read/write mode
  1238.     inc    eax
  1239.     jz    .EndReal
  1240.  
  1241.     dec    eax
  1242.  
  1243.     push     eax            ; Save Handle
  1244. ;────────────────────────────────────────────────────────────────────────────
  1245. ; Read 1024 bytes (grab header).
  1246. ;────────────────────────────────────────────────────────────────────────────
  1247.     push     byte 0
  1248.     lea    ebx, [ebp-4]
  1249.     push     ebx
  1250.     push     dword 1000h
  1251.     push     dword [ebp+0Ch]
  1252.     push     eax
  1253.     call     ReadFile
  1254.     pop    ebx
  1255.     push    eax
  1256.  
  1257. ;────────────────────────────────────────────────────────────────────────────
  1258. ; Close File.
  1259. ;────────────────────────────────────────────────────────────────────────────
  1260.     push    ebx
  1261.     call     CloseHandle            ; Close File
  1262.     pop    eax
  1263.  
  1264. .EndReal:
  1265.     pop    ebx
  1266.     pop    edx
  1267.     pop    ecx
  1268.     pop    edi
  1269.     pop    esi
  1270.     add    esp, byte 4
  1271.     pop    ebp
  1272.     retn      08h
  1273.  
  1274.  
  1275. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1276. ; Check if buffer contains a Valid PE structure.
  1277. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1278.  
  1279. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1280. ;esp+4 : buffer
  1281. ;
  1282. ;eax contains PE start on success, 0 otherwise.
  1283. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1284. CheckPE:
  1285.     push     esi
  1286.  
  1287.     mov      esi, [esp+04h+04h]    ; Load buffer
  1288.  
  1289.     xor      eax, eax
  1290.     cmp      word [esi], 'MZ'           ; check MZ sig.
  1291.     jnz      .EndCheckPE
  1292.  
  1293.     push     esi
  1294.       add      esi, byte 3ch
  1295.     lodsd
  1296.       pop      esi
  1297.       cmp      word [esi+eax], 'PE'    ; check  PE signature
  1298.       jz       .EndCheckPE
  1299.  
  1300.     xor      eax, eax
  1301.  
  1302. .EndCheckPE:
  1303.     pop      esi
  1304.     retn    04h
  1305.  
  1306.  
  1307. ;iceload.ini stuff.
  1308. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1309. ; GetLastFile: reads LastFile and LastDir from %windir%\iceload.ini
  1310. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1311. GetLastFile:
  1312.     push    ebp
  1313.     mov    ebp, esp
  1314.     pushad
  1315.  
  1316.     push    dword strIniFile        ;iceload.ini
  1317.     push    dword 256
  1318.     push    dword __Source
  1319.     push    byte 0                ;defstring
  1320.     push    dword strLastFile        ;"LastFile"
  1321.     push    dword strAppName        ;"iceload"
  1322.     call    GetPrivateProfileStringA
  1323.  
  1324.     push    dword strIniFile        ;iceload.ini
  1325.     push    dword 256
  1326.     push    dword IniDirBuffer
  1327.     push    byte 0                ;defstring
  1328.     push    dword strLastDir        ;"LastDir"
  1329.     push    dword strAppName        ;"iceload"
  1330.     call    GetPrivateProfileStringA
  1331.     test    eax, eax
  1332.     jz    .EndGetLastFile
  1333.  
  1334.     mov    dword [IL_ofn+OPENFILENAME.lpstrInitialDir], IniDirBuffer
  1335.  
  1336. .EndGetLastFile:
  1337.  
  1338.     popad
  1339.     pop    ebp
  1340.     ret
  1341.  
  1342.  
  1343. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1344. ; UpdateIni: writes LastFile and LastDir to %windir%\iceload.ini
  1345. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1346. UpdateIni:
  1347.     push    ebp
  1348.     mov    ebp, esp
  1349.     pushad
  1350.  
  1351.     push    dword __Source            ;fullpath+filename
  1352.     call    lstrlenA
  1353.     mov    ecx, eax
  1354.     mov    edi, dword __Source
  1355.     add    edi, eax
  1356.     mov    al,'\'
  1357.     std
  1358.     repnz    scasb                ;reverse scan for '\'
  1359.     cld
  1360.     mov    edi, dword __Source + 2
  1361.     add    edi, ecx            ;edi = file w/o path
  1362.  
  1363.     push    ecx                ;save pos
  1364.  
  1365.     push    dword strIniFile        ;iceload.ini
  1366.     push    edi
  1367.     push    dword strLastFile        ;"LastFile"
  1368.     push    dword strAppName        ;"iceload"
  1369.     call    WritePrivateProfileStringA
  1370.  
  1371.     pop    ecx
  1372.     mov    al, [__Source + 2 + ecx]
  1373.     mov    byte [__Source + 2 + ecx],0    ;replace 1. letter of filename w/ 0
  1374.     push    eax
  1375.     push    ecx
  1376.  
  1377.     push    dword strIniFile        ;iceload.ini
  1378.     push    dword __Source
  1379.     push    dword strLastDir        ;"LastDir"
  1380.     push    dword strAppName        ;"iceload"
  1381.     call    WritePrivateProfileStringA
  1382.  
  1383.     pop    ecx
  1384.     pop    eax
  1385.     mov    [__Source + 2 + ecx],al        ;restore 1. letter
  1386.  
  1387.     popad
  1388.     pop    ebp
  1389.     ret
  1390.  
  1391.  
  1392. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1393. ; SaveCurrentPos: writes LastPos of dialog to %windir%\iceload.ini
  1394. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1395.  
  1396. SaveCurrentPos:
  1397.     push    ebp
  1398.     mov    ebp, esp
  1399.     sub    esp, byte RECT_size + 20
  1400.     pushad
  1401.  
  1402.     cmp    byte [fIsMinimized], 1
  1403.     jz    near .EndSaveCurrentPos
  1404.  
  1405.     lea    esi, [ebp-RECT_size]
  1406.     push    esi
  1407.     push    dword [ebp+08h]
  1408.     call    GetWindowRect
  1409.  
  1410.     lea    edi, [ebp-RECT_size-20]
  1411.  
  1412.     push    edi                    ;buffer
  1413.     push    dword [esi+RECT.left]
  1414.     call    Dword2Hex
  1415.     mov    byte [edi+8], ','
  1416.     add    edi, byte 9
  1417.  
  1418.     push    edi                    ;buffer
  1419.     push    dword [esi+RECT.top]
  1420.     call    Dword2Hex
  1421.     mov    byte [edi+8], 0
  1422.  
  1423.     lea    edi, [ebp-RECT_size-20]
  1424.     push    dword strIniFile            ;iceload.ini
  1425.     push    edi
  1426.     push    dword strLastPos            ;"LastPos"
  1427.     push    dword strAppName            ;"iceload"
  1428.     call    WritePrivateProfileStringA
  1429.  
  1430. .EndSaveCurrentPos:
  1431.     popad
  1432.     add    esp, byte RECT_size + 20
  1433.     pop    ebp
  1434.     retn    04h
  1435.  
  1436.  
  1437. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1438. ; RestoreLastPos: reads LastPos from %windir%\iceload.ini and moves dlg
  1439. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1440.  
  1441. RestoreLastPos:
  1442.     push    ebp
  1443.     mov    ebp, esp
  1444.     sub    esp, byte RECT_size + 20
  1445.     pushad
  1446.  
  1447.     lea    edi, [ebp-RECT_size-20]
  1448.     push    dword strIniFile        ;iceload.ini
  1449.     push    byte 18
  1450.     push    edi
  1451.     push    byte 0                ;defstring
  1452.     push    dword strLastPos        ;"LastDir"
  1453.     push    dword strAppName        ;"iceload"
  1454.     call    GetPrivateProfileStringA
  1455.     test    eax, eax
  1456.     jz    .EndRestorePos
  1457.  
  1458.     lea    edi, [ebp-RECT_size]
  1459.     lea    esi, [ebp-RECT_size-20]
  1460.  
  1461.     mov    byte [esi +  8], 0
  1462.     push    esi
  1463.     call    Hex2Dec
  1464.     mov    dword [edi+RECT.left], eax
  1465.  
  1466.     add    esi, byte 9
  1467.     mov    byte [esi +  8], 0
  1468.     push    esi
  1469.     call    Hex2Dec
  1470.     mov    dword [edi+RECT.top], eax
  1471.  
  1472.  
  1473.     lea    edi, [ebp-RECT_size]
  1474.     push    byte TRUE
  1475.     push    dword 257
  1476.     push    dword 390
  1477.     push    dword [edi+RECT.top]
  1478.     push    dword [edi+RECT.left]
  1479.     push    dword [ebp+08h]
  1480.     call    MoveWindow
  1481.  
  1482. .EndRestorePos:
  1483.     popad
  1484.     add    esp, byte RECT_size + 20
  1485.     pop    ebp
  1486.     retn    04h
  1487.  
  1488.  
  1489. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1490. ; LoadExports: loads exports of a pe to winice
  1491. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1492. %define hDlg              ebp + 8
  1493. %define hNMLib             ebp - 4
  1494. %define strFname         ebp - (4 + 256)
  1495. %define ofn               ebp - (4 + 256 + OPENFILENAME_size)
  1496. LoadExports:
  1497.     push    ebp
  1498.     mov    ebp, esp
  1499.     sub    esp, dword (4 + 256 + OPENFILENAME_size)    ;func ptr + buff + ofn struct
  1500.  
  1501.     lea    esi, [ofn]                    ;OPENFILENAME struct
  1502.     mov    edi, esi
  1503.     mov    ecx, (OPENFILENAME_size+256)
  1504.     xor    eax,eax
  1505.     rep    stosb
  1506.  
  1507.     lea    edi, [strFname]                    ;str buff
  1508.  
  1509.      mov    dword [esi+OPENFILENAME.lStructSize], OPENFILENAME_size
  1510.     mov    eax, [hDlg]
  1511.     mov    [esi+OPENFILENAME.hwndOwner], eax
  1512.     mov    eax, [hInst]
  1513.     mov    [esi+OPENFILENAME.hInstance], eax
  1514.     mov    dword [esi+OPENFILENAME.lpstrFilter], strFilter
  1515.     mov    dword [esi+OPENFILENAME.lpstrFile], edi
  1516.     mov    dword [esi+OPENFILENAME.nMaxFile], 256
  1517.     mov    dword [esi+OPENFILENAME.Flags], OFN_HIDEREADONLY | OFN_FILEMUSTEXIST
  1518.     mov    dword [esi+OPENFILENAME.lpstrDefExt], strDefExt
  1519.  
  1520.     push    esi
  1521.     call    GetOpenFileNameA
  1522.     test    al, al
  1523.     jz    near .EndLoadExp
  1524.  
  1525.     push    dword NMLIB
  1526.     call    LoadLibraryA            ;load nmtrans.dll
  1527.     test    eax, eax
  1528.     jz    near .EndLoadExp
  1529.  
  1530.     mov    [hNMLib], eax
  1531.  
  1532.     push    dword NMLoadExports
  1533.     push    dword [hNMLib]
  1534.     call    GetProcAddress          ;get NmSymLoadExports address
  1535.     test    eax, eax
  1536.     jz      near .EndFreeLib
  1537.  
  1538.     push    dword [esi+OPENFILENAME.lpstrFile]
  1539.     call    eax            ;call NmSymLoadExports
  1540.     add    esp, byte 4
  1541.     test    al, al
  1542.     jz      near .ErrTextOut
  1543.  
  1544.     push    byte 1
  1545.     push    dword strExpLoaded
  1546.     push    dword IL_STATUS
  1547.     push    dword [hDlg]
  1548.     Call    TextBoxWrite        ;"Exports loaded for:"
  1549.     push    byte 1
  1550.     push    dword [esi+OPENFILENAME.lpstrFile]
  1551.     push    dword IL_STATUS
  1552.     push    dword [hDlg]
  1553.     Call    TextBoxWrite
  1554.     jmp    near .EndFreeLib
  1555.  
  1556. .ErrTextOut:
  1557.     push    byte 1
  1558.     push    dword strErrExpLoaded
  1559.     push    dword IL_STATUS
  1560.     push    dword [hDlg]
  1561.     Call    TextBoxWrite        ;"Error loading exports !!"
  1562.  
  1563. .EndFreeLib:
  1564.     push    dword [hNMLib]
  1565.     call    FreeLibrary        ;free dll
  1566.  
  1567. .EndLoadExp:
  1568.  
  1569.     add    esp, dword (4 + 256 + OPENFILENAME_size)
  1570.     pop    ebp
  1571.     retn    04h
  1572.  
  1573.  
  1574. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1575. ; SaveSIHist: save winice history to a log file
  1576. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1577. SaveSIHist:
  1578.     push    ebp
  1579.     mov    ebp, esp
  1580.     sub    esp, dword (4 + 256 + OPENFILENAME_size)    ;func ptr + buff + ofn struct
  1581.  
  1582.  
  1583.     lea    esi, [ofn]                    ;OPENFILENAME struct
  1584.     mov    edi, esi
  1585.     mov    ecx, OPENFILENAME_size+256
  1586.     xor    eax ,eax
  1587.     rep    stosb
  1588.  
  1589.     lea    edi, [strFname]                    ;str buff
  1590.  
  1591.      mov    dword [esi+OPENFILENAME.lStructSize], OPENFILENAME_size
  1592.     mov    eax, [hDlg]
  1593.     mov    [esi+OPENFILENAME.hwndOwner], eax
  1594.     mov    eax, [hInst]
  1595.     mov    [esi+OPENFILENAME.hInstance], eax
  1596.     mov    dword [esi+OPENFILENAME.lpstrFilter], strFilter2
  1597.     mov    dword [esi+OPENFILENAME.lpstrFile], edi
  1598.     mov    dword [esi+OPENFILENAME.nMaxFile], 256
  1599.     mov    dword [esi+OPENFILENAME.Flags], OFN_HIDEREADONLY
  1600.     mov    dword [esi+OPENFILENAME.lpstrDefExt], strDefLogExt
  1601.  
  1602.     push    esi
  1603.     call    GetSaveFileNameA
  1604.     test    al, al
  1605.     jz    near .EndSaveSiHist    ;did user push cancel?
  1606.  
  1607.     push    dword NMLIB
  1608.     call    LoadLibraryA            ;load nmtrans.dll
  1609.     test    eax, eax
  1610.     jz    near .EndSaveSiHist
  1611.  
  1612.     mov    [hNMLib], eax
  1613.  
  1614.     push    dword NMCreateLog
  1615.     push    dword [hNMLib]
  1616.     call    GetProcAddress          ;get NmSymCreateLogFile address
  1617.     test    eax, eax
  1618.     jz      near .EndSaveFreeLib
  1619.  
  1620.     push    byte -1
  1621.     push    byte 0
  1622.     push    dword [esi+OPENFILENAME.lpstrFile]
  1623.     call    eax            ;call NmSymCreateLogFile
  1624.     add     esp, byte 0Ch
  1625.     test    al, al
  1626.     jz      near .ErrSaveTextOut
  1627.     push    byte 1
  1628.     push    dword strSiHistSaved
  1629.     push    dword IL_STATUS
  1630.     push    dword [hDlg]
  1631.     Call    TextBoxWrite        ;"SoftIce history saved"
  1632.  
  1633.     push    byte 1
  1634.     push    dword [esi+OPENFILENAME.lpstrFile]
  1635.     push    dword IL_STATUS
  1636.     push    dword [hDlg]
  1637.     Call    TextBoxWrite
  1638.     jmp    near .EndSaveFreeLib
  1639.  
  1640. .ErrSaveTextOut:
  1641.     push    byte 1
  1642.     push    dword strErrSiHistSaved
  1643.     push    dword IL_STATUS
  1644.     push    dword [hDlg]
  1645.     Call    TextBoxWrite        ;"Error saving SoftIce history !!"
  1646.  
  1647. .EndSaveFreeLib:
  1648.     push    dword [hNMLib]
  1649.     call    FreeLibrary        ;free dll
  1650.  
  1651. .EndSaveSiHist:
  1652.  
  1653.     add    esp, dword (4 + 256 + OPENFILENAME_size)
  1654.     pop    ebp
  1655.     retn    04h
  1656.  
  1657. %undef hDlg
  1658. %undef hNMLib
  1659. %undef strFname
  1660. %undef ofn
  1661.  
  1662.  
  1663. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1664. ; SetToolbarTTs: set the proper Tooltiptext for the button in the toolbar
  1665. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1666. %define lpParam    ebp + 8
  1667. SetToolbarTTs:
  1668.     push    ebp
  1669.     mov    ebp, esp
  1670.     push    esi
  1671.     push    edi
  1672.     
  1673.     mov    esi, [lpParam]                ;TOOLTIPTEXT->NMHDR
  1674.  
  1675.     cmp    dword [esi+NMHDR.code], TTN_NEEDTEXT
  1676.     jnz    near .EndSetToolBarTTs
  1677.  
  1678.     mov    eax, [esi+NMHDR.idFrom]
  1679.     sub    eax, 1000
  1680.     mov    edi, TT_Strings_Table
  1681.     mov    edi, [edi + eax * 4]
  1682.     mov    [esi+0Ch], edi                ;set tooltip text
  1683.  
  1684. .EndSetToolBarTTs:
  1685.     xor    eax, eax
  1686.     pop    edi
  1687.     pop    esi
  1688.     pop    ebp
  1689.     retn    04h
  1690. %undef lpParam
  1691.